<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>活动管理</title>
    <link href="$!webPath/css/template.css"  rel="stylesheet" type="text/css">
    <link href="$!webPath/css/jquery-ui-1.8.22.custom.css" type=text/css rel=stylesheet>
    <script src="$!webPath/js/jquery.min.js"></script>
    <script src="$!webPath/js/jquery-ui-1.8.21.js"></script>
    <script>
        function activeDel(id){
            if(confirm("你确定要删除吗？")){
                $.ajax({
                    url:'$!webPath/admin/deleteActivity?activityId='+id,
                    type:'delete',
                    success: function () {
                        $('#'+id).remove();
                        window.location.reload();
                    },
                    error:function(){
                        alert('删除失败');
                    }
                })
            }
        }
        function jfs(){
            $.ajax({
                url:'$!webPath/admin/listAllActivity?size=10&page=0&type=0',
                success:function(){
                    $('#div_jfs').show();
                    $('#div_xls').hide();
                }
            })
        }
        function xls(){
            $.ajax({
                url:'$!webPath/admin/listAllActivity?size=10&page=0&type=1',
                success:function(){
                    $('#div_jfs').hide();
                    $('#div_xls').show();
                }
            })
        }
    </script>
</head>
<body>

<div class="header_nav">
    <iframe name="content_frame" src="$!webPath/admin/nav" marginwidth=0 marginheight=0  frameborder=0 width=100% height=80/></iframe>
    <div class="cont_right"><a href="$!webPath/login">注销</a></div>
</div>
<div class="cont">
    <h3 class="seth">活动管理</h3>
    <div class="nav_list">
        <ul>
            <li><a href="$!webPath/admin/listAllActivity?size=10&page=0&type=0" onclick="return jfs()" class="this"><b>积分排名赛</b></a></li>
            <li><a href="$!webPath/admin/listAllActivity?size=10&page=0&type=1" onclick="return xls()" class="this"><b>系列赛</b></a></li>
            <li><a href="$!webPath/admin/activity_page"><b>添加活动</b></a></li>
        </ul>
    </div>
    <form action="" method="post" id="ListForm" >
        <div class="fshoptb">
            <div id="div_jfs">
                <table id="jfs" width="100%" border="0" cellspacing="0" cellpadding="0" class="fshop_table">
                    <thead width="100%" align="center">积分排名赛</thead>
                    <tr>
                        <th width="5%">序号</th>
                        <th width="10%" align="center">活动名称</th>
                        <th width="12%" align="center">活动场地</th>
                        <th width="12%" align="center">开始时间</th>
                        <th width="12%" align="center">截止时间</th>
                        <th width="10%" align="center">创建人</th>
                        <th width="10%" align="center">更新人</th>
                        <th align="center">操作</th>
                    </tr>
                    <tbody id="activityEntities">
                    #foreach($obj in $!activityEntities)
                        <tr id="$!obj.id">
                            <td align="center">$!obj.activitySequence</td>
                            <td align="center">$!obj.activityName</td>
                            <td align="center">$!obj.activityLocation</td>
                            <td align="center">$!obj.activityTime</td>
                            <td align="center">$!obj.applyDeadLine</td>
                            <td align="center">$!obj.createdBy</td>
                            <td align="center">$!obj.updateBy</td>
                            <td align="center" class="hui oprate_con">
                                <a href="#" onclick="return activeDel('$!obj.id')" class="blue">删除</a>
                                <a href="$!webPath/admin/activity_page?activityId=$!obj.id" class="blue">编辑</a>
                                <a href="$!webPath/admin/activityContent?activityId=$!obj.id" class="blue">查看</a>
                                <a href="$!webPath/admin/matchList?activityId=$!obj.id" class="blue">赛事</a>
                            </td>
                        </tr>

                    #end
                    </tbody>
                </table>
                <span id="spanFirst">第一页</span> <span id="spanPre">上一页</span> <span id="spanNext">下一页</span>
            </div>
            <br/>
            <div id="div_xls" style="display:none;">
                <table id="xls" width="100%" border="0" cellspacing="0" cellpadding="0" class="fshop_table">
                    <thead width="100%" align="center">系列赛</thead>
                    <tr>
                        <th width="5%">序号</th>
                        <th width="10%" align="center">活动名称</th>
                        <th width="12%" align="center">活动场地</th>
                        <th width="12%" align="center">开始时间</th>
                        <th width="12%" align="center">截止时间</th>
                        <th width="10%" align="center">创建人</th>
                        <th width="10%" align="center">更新人</th>
                        <th align="center">操作</th>
                    </tr>
                    <tbody id="activityEntities1">

                    #foreach($obj in $!activityEntities)

                    <tr id="$!obj.id">
                        <td align="center">$!obj.activitySequence</td>
                        <td align="center">$!obj.activityName</td>
                        <td align="center">$!obj.activityLocation</td>
                        <td align="center">$!obj.activityTime</td>
                        <td align="center">$!obj.applyDeadLine</td>
                        <td align="center">$!obj.createdBy</td>
                        <td align="center">$!obj.updateBy</td>
                        <td align="center" class="hui oprate_con">
                            <a href="#" onclick="return activeDel('$!obj.id')" class="blue">删除</a>
                            <a href="$!webPath/admin/activity_page?activityId=$!obj.id" class="blue">编辑</a>
                            <a href="$!webPath/admin/activityContent?activityId=$!obj.id" class="blue">查看</a>
                        </td>
                    </tr>

                    #end
                    </tbody>
                </table>
                <span id="spanFirst1">第一页</span> <span id="spanPre1">上一页</span> <span id="spanNext1">下一页</span>
            </div>
        </div>
        <div class="operate_bar">
            <div class="fenye">
                $!gotoPageFormHTML
            </div>
        </div>
    </form>
</div>
<script>
    getUrlParam = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }

    //替换指定传入参数的值,paramName为参数,replaceWith为新值
    function replaceParamVal(paramName,replaceWith) {
        var oUrl = this.location.href.toString();
        var re=eval('/('+ paramName+'=)([^&]*)/gi');
        var nUrl = oUrl.replace(re,paramName+'='+replaceWith);
        this.location = nUrl;
    }
    var page = getUrlParam('page');
    $('#spanFirst').click(function () {
        page=0;
        $.ajax({
            url:'$!webPath/admin/listAllActivity?size=10&type=0&page='+page,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/admin/listAllActivity?size=10&type=0&page='+page;
                replaceParamVal('page',page);
            }
        })
    })
    var nextpage=0;
    $('#spanNext').click(function(){
        nextpage++;
        $.ajax({
            url:'$!webPath/admin/listAllActivity?size=10&type=0&page='+nextpage,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/admin/listAllActivity?size=10&type=0&page='+page;
                replaceParamVal('page',nextpage);
            }
        })
    })

    $('#spanPre').click(function(){
        nextpage--;
        if(nextpage<=0){
            nextpage=0;
        }
        $.ajax({
            url:'$!webPath/admin/listAllActivity?size=10&type=0&page='+nextpage,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/admin/listAllActivity?size=10&type=0&page='+page;
                replaceParamVal('page',nextpage);
            }
        })
    })
    var prepage=0;
    $('#spanFirst1').click(function () {
        page=0
        $.ajax({
            url:'$!webPath/admin/listAllActivity?size=10&type=1&page='+page,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/admin/listAllActivity?size=10&type=1&page='+page;
                replaceParamVal('page',page);
            }
        })
    })

    $('#spanNext1').click(function(){
        prepage++;
        $.ajax({
            url:'$!webPath/admin/listAllActivity?size=10&type=1&page='+prepage,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/admin/listAllActivity?size=10&type=1&page='+page;
                replaceParamVal('page',page);
            }
        })
    })

    $('#spanPre1').click(function(){
        prepage--;
        if(prepage<=0){
            prepage=0;
        }
        $.ajax({
            url:'$!webPath/admin/listAllActivity?size=10&type=1&page='+prepage,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/admin/listAllActivity?size=10&type=1&page='+page;
                replaceParamVal('page',prepage);
            }
        })
    })
</script>

</body>
</html>
